package com.itheima.sparkml.exercise
import org.apache.spark.mllib.linalg
import org.apache.spark.mllib.linalg.Vectors

/**
  * DESC:
  * Complete data processing and modeling process steps:
  * //linglg含义代表是线性代数的含义
  * 向量：一组数据通过小括号链接起来（1，2，3，4，5）
  */
object LocalVector1 {
  def main(args: Array[String]): Unit = {
      val vector1 = Vectors.dense(1.0,2.0,3.0)
      val vector2 = Vectors.dense(Array(1.1,2.1,3.1))
    //稠密性向量----存储下标位置和值
    println("vector1 is "+vector1)
    println("vector2 is "+vector2)
    println("the second element of vector2 is "+vector2(1))
    println("=========================")
    val vector3=Vectors.sparse(10,Array(1,3,5,7,9),Array(2.1,3.1,4.1,5.1,6.1))
    val seq=Seq((1,2.2),(3,2.5),(8,3.3))
    val vector4 = Vectors.sparse(9,seq)
    println("vector3 is"+vector3)
    println("vector4 is"+vector4)
    println(vector3(2))
    println(vector3(4))
    println(vector3(6))
    println(vector3(8))
  }
}
